package com.brand.prisd.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.brand.prisd.R;

/**
 * 选择创建账户或者登录已有账户界面
 */
public class SelectAccountActivity extends AppCompatActivity implements View.OnClickListener {

    private Button btn_createNewAccount;
    private Button btn_existingAccount;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_select_account);
        initView();
    }

    private void initView() {
        btn_createNewAccount = findViewById(R.id.btn_createNewAccount);
        btn_createNewAccount.setOnClickListener(this);
        btn_existingAccount = findViewById(R.id.btn_existingAccount);
        btn_existingAccount.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.btn_createNewAccount:
                startActivity(new Intent(this, RegisterActivity.class));
                finish();
                break;
            case R.id.btn_existingAccount:
                startActivity(new Intent(this, LoginActivity.class));
                finish();
                break;
        }

    }
    long last = 0;
    @Override
    public void onBackPressed() {
        long L = System.currentTimeMillis();
        if (L - last >= 3000) {
            Toast.makeText(this, "再按一次退出 PRISD", Toast.LENGTH_SHORT).show();
        } else {
            finish();
        }
        last = L;
    }
}
